/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CreateTaskFrame.java
 *
 * Created on 13.11.2009, 19:03:34
 */
package iddsgui;

import Main.Parameters;
import java.io.File;
import plugin.PluginLoader;

/**
 *
 * @author zem
 */
public class CreateTaskFrame extends javax.swing.JFrame {

    private static Object[][] SubtasksRows;
    private static CreateTaskFrame instance;
    private static String[] plugins_list;
    private static String[] plugin_parameters_list;
    private static String[] plugin_groups_list;
    private static String[][] plugin_group_parameters_list;

    /** Creates new form CreateTaskFrame */
    public CreateTaskFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        TaskNameTextField = new javax.swing.JTextField();
        NameLabel = new javax.swing.JLabel();
        SaveTaskButton = new javax.swing.JToggleButton();
        TaskCheckButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        Subtasks = new javax.swing.JTable();
        PluginsComboBox = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        PluginLabel = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        ParameterLabel = new javax.swing.JLabel();
        ParameterComboBox = new javax.swing.JComboBox();
        jTextField1 = new javax.swing.JTextField();
        ValueLabel = new javax.swing.JLabel();
        AddParameterButton = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JSeparator();
        GroupLabel = new javax.swing.JLabel();
        GroupComboBox = new javax.swing.JComboBox();
        GroupParameterLabel = new javax.swing.JLabel();
        GroupParameterComboBox = new javax.swing.JComboBox();
        jTextField2 = new javax.swing.JTextField();
        GroupParameterValueLabel = new javax.swing.JLabel();
        AddGroupParameterValueButton = new javax.swing.JButton();
        AddGroupButton = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        SubtaskTree = new javax.swing.JTree();
        jLabel6 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jButton7 = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JSeparator();
        TaskStartUpLabel = new javax.swing.JLabel();
        TaskPriorityLabel = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        SubtaskPriorityLabel = new javax.swing.JLabel();
        SubtaskPriorityTextField = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(800, 600));

        NameLabel.setText(Parameters.GUI_TaskCreateFrame_TaskNameLabel);

        SaveTaskButton.setText(Parameters.GUI_TaskCreateFrame_TaskSaveButton);

        TaskCheckButton.setText(Parameters.GUI_TaskCreateFrame_TaskCheckButton);

        Subtasks.setModel(new javax.swing.table.DefaultTableModel(
            SubtasksRows,
            new String [] {"", ""}
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        Subtasks.setSurrendersFocusOnKeystroke(true);
        jScrollPane1.setViewportView(Subtasks);

        PluginsComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PluginsComboBoxActionPerformed(evt);
            }
        });

        jButton1.setText(Parameters.GUI_TaskCreateFrame_AddSubtaskButton);

        jButton2.setText(Parameters.GUI_TaskCreateFrame_RemoveSubtaskButton);

        jButton3.setText(Parameters.GUI_TaskCreateFrame_ChangeSubtaskButton);

        PluginLabel.setText(Parameters.GUI_TaskCreateFrame_PluginLabel);

        ParameterLabel.setText(Parameters.GUI_TaskCreateFrame_ParameterLabel);

        ValueLabel.setText(Parameters.GUI_TaskCreateFrame_ParameterValueLabel);

        AddParameterButton.setText(Parameters.GUI_TaskCreateFrame_AddParameterValueButton);

        GroupLabel.setText(Parameters.GUI_TaskCreateFrame_GroupLabel);

        GroupComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GroupComboBoxActionPerformed(evt);
            }
        });

        GroupParameterLabel.setText(Parameters.GUI_TaskCreateFrame_GroupParameterLabel);

        GroupParameterValueLabel.setText(Parameters.GUI_TaskCreateFrame_GroupParameterValueLabel);

        AddGroupParameterValueButton.setText(Parameters.GUI_TaskCreateFrame_AddGroupParameterButton);

        AddGroupButton.setText(Parameters.GUI_TaskCreateFrame_AddGroupButton);

        jScrollPane2.setViewportView(SubtaskTree);

        jLabel6.setText(Parameters.GUI_TaskCreateFrame_ParameterValueLabel);

        jButton7.setText(Parameters.GUI_TaskCreateFrame_ChangeValueButton);

        TaskStartUpLabel.setText(Parameters.GUI_TaskCreateFrame_TaskStartUpLabel);

        TaskPriorityLabel.setText(Parameters.GUI_TaskCreateFrame_TaskPriorityLabel);

        SubtaskPriorityLabel.setText(Parameters.GUI_TaskCreateFrame_SubtaskPriorityLabel);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(NameLabel)
                .addGap(18, 18, 18)
                .addComponent(TaskNameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 509, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TaskCheckButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(SaveTaskButton))
            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 830, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 315, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(TaskPriorityLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField5, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(TaskStartUpLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 491, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(PluginLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(PluginsComboBox, 0, 171, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(SubtaskPriorityLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(SubtaskPriorityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 491, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(ValueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(ParameterLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(AddParameterButton))
                                    .addComponent(ParameterComboBox, 0, 390, Short.MAX_VALUE)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(GroupParameterLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(GroupParameterComboBox, 0, 390, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(GroupLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(GroupComboBox, 0, 283, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(AddGroupButton))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(GroupParameterValueLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(AddGroupParameterValueButton)))
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton7))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 491, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(NameLabel)
                    .addComponent(TaskNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(SaveTaskButton)
                    .addComponent(TaskCheckButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(TaskStartUpLabel)
                            .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(TaskPriorityLabel)
                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(PluginLabel)
                            .addComponent(PluginsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(SubtaskPriorityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(SubtaskPriorityLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ParameterLabel)
                            .addComponent(ParameterComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ValueLabel)
                            .addComponent(AddParameterButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(GroupLabel)
                            .addComponent(GroupComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(AddGroupButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(GroupParameterLabel)
                            .addComponent(GroupParameterComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(GroupParameterValueLabel)
                            .addComponent(AddGroupParameterValueButton))
                        .addGap(30, 30, 30)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 570, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton3)
                    .addComponent(jButton2)
                    .addComponent(jButton1)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jButton7)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Plugin has been chosen
     * @param evt - the event
     */
    private void PluginsComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PluginsComboBoxActionPerformed
        //if selected index more then 0
        if (instance.PluginsComboBox.getSelectedIndex() != 0) {
            //get chosen plugin name
            String plugin_name = (String) instance.PluginsComboBox.getSelectedItem();

            //load plugin
            PluginLoader PL = new PluginLoader();
            if (PL.Load(plugin_name)) {

                if (PL.HasParameters()) {
                    //read parameters names
                    plugin_parameters_list = PL.GetPluginParameters();
                    plugin_groups_list = PL.GetPluginGroups();
                    plugin_group_parameters_list = PL.GetPluginGroupParameters();
                    //remove all items from parameters combo boxes
                    instance.GroupComboBox.removeAllItems();
                    instance.GroupParameterComboBox.removeAllItems();
                    instance.ParameterComboBox.removeAllItems();

                    //input parameters into ParameterComboBox
                    if (plugin_parameters_list != null) { //if plugin has parameters
                        instance.ParameterComboBox.addItem(Parameters.GUI_TaskCreateFrame_ParametersComboBox_ChooseParameter);
                        for (int i = 0; i < plugin_parameters_list.length; i++) {
                            instance.ParameterComboBox.addItem(plugin_parameters_list[i]);
                        }
                    }
                    //input groups into GroupComboBox
                    if (plugin_groups_list != null) { //if plugin has groups
                        instance.GroupComboBox.addItem(Parameters.GUI_TaskCreateFrame_GroupComboBox_ChooseGroup);
                        for (int i = 0; i < plugin_groups_list.length; i++) {
                            instance.GroupComboBox.addItem(plugin_groups_list[i]);
                        }
                    }
                }
            }
        }



    }//GEN-LAST:event_PluginsComboBoxActionPerformed

    /**
     * Group Combo Box  - group accept
     * @param evt action event
     */
    private void GroupComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GroupComboBoxActionPerformed
        //if selected index is not 0
        if(instance.GroupComboBox.getSelectedIndex()>0){
            //remove all items in GroupParameter Combo box
            instance.GroupParameterComboBox.removeAllItems();

            //input group parameters into GroupParameterComboBox
                    if (plugin_group_parameters_list[GroupComboBox.getSelectedIndex()-1] != null) { //if plugin has parameters for such group
                        instance.GroupParameterComboBox.addItem(Parameters.GUI_TaskCreateFrame_GroupParametersComboBox_ChooseParameter);
                        for (int i = 0; i < plugin_group_parameters_list[GroupComboBox.getSelectedIndex()-1].length; i++) {
                            instance.GroupParameterComboBox.addItem(plugin_group_parameters_list[GroupComboBox.getSelectedIndex()-1][i]);
                        }
                    }

        }
    }//GEN-LAST:event_GroupComboBoxActionPerformed

    /**
     * @param args the command line arguments
     */
    public void main() {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                SubtasksRows = new Object[][]{{null, null}, {null, null}};
                instance = new CreateTaskFrame();
                instance.setTitle(Parameters.GUI_TaskCreateFrame_Title);
                plugins_list = GetPlugins();
                instance.PluginsComboBox.addItem(Parameters.GUI_TaskCreateFrame_PluginsComboBox_ChoosePlugin);
                for (int i = 0; i < plugins_list.length; i++) {
                    instance.PluginsComboBox.addItem(plugins_list[i]);

                }

                instance.setVisible(true);

            }
        });
    }

    /**
     * return name of plugins located in plugin direcrory
     * @return
     */
    private String[] GetPlugins() {
        File plugindirectory = new File(Parameters.PluginDirectory);
        File[] in = plugindirectory.listFiles();
        //if plugin folder is not empty
        if (in != null) {

            String[] buffer = new String[in.length];
            String[] names;
            int p = -1;
            //loop of checking files in plugin folder to be directories
            for (int i = 0; i < in.length; i++) {
                if (in[i].isDirectory()) {
                    //check if directory has main plugin jar file
                    File[] plugin_files = in[i].listFiles();
                    if (plugin_files != null) {
                        //loop of finding main plugin jar file
                        boolean find = false; //flag (if true than main plugin jar file was found)
                        int j = 0;
                        do {
                            if (plugin_files[j].getName().equals(in[i].getName() + ".jar")) {
                                find = true;
                            }
                            j++;
                        } while ((j < plugin_files.length) | !find);
                        //if main plugin jar file found
                        if (find) {
                            //insert to buffer plugin name
                            p++;
                            buffer[p] = in[i].getName();
                        }
                    }
                }
            }
            //if found 1 or more plugins
            if (p > -1) {
                names = new String[p + 1];
                for (int i = 0; i < p + 1; i++) {
                    names[i] = buffer[i];
                }
                return names;
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AddGroupButton;
    private javax.swing.JButton AddGroupParameterValueButton;
    private javax.swing.JButton AddParameterButton;
    private javax.swing.JComboBox GroupComboBox;
    private javax.swing.JLabel GroupLabel;
    private javax.swing.JComboBox GroupParameterComboBox;
    private javax.swing.JLabel GroupParameterLabel;
    private javax.swing.JLabel GroupParameterValueLabel;
    private javax.swing.JLabel NameLabel;
    private javax.swing.JComboBox ParameterComboBox;
    private javax.swing.JLabel ParameterLabel;
    private javax.swing.JLabel PluginLabel;
    private javax.swing.JComboBox PluginsComboBox;
    private javax.swing.JToggleButton SaveTaskButton;
    private javax.swing.JLabel SubtaskPriorityLabel;
    private javax.swing.JTextField SubtaskPriorityTextField;
    private javax.swing.JTree SubtaskTree;
    private javax.swing.JTable Subtasks;
    private javax.swing.JButton TaskCheckButton;
    private javax.swing.JTextField TaskNameTextField;
    private javax.swing.JLabel TaskPriorityLabel;
    private javax.swing.JLabel TaskStartUpLabel;
    private javax.swing.JLabel ValueLabel;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton7;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    // End of variables declaration//GEN-END:variables
}
